<html>
<head><meta charset="utf-8"><title>building cargo-miri · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/building.20cargo-miri.html">building cargo-miri</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="244872964"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/building%20cargo-miri/near/244872964" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Huszagh (He/Him) <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/building.20cargo-miri.html#244872964">(Jul 04 2021 at 19:10)</a>:</h4>
<p>Does anyone know why cargo-miri would be using outdated versions of rust-core, from a custom build?</p>
<p>Detailed install instructions, FYI: from a  custom version of rust, from the directory, I first build the package, and then copy the binaries over, and then link the toolchain.</p>
<div class="codehilite" data-code-language="Bash"><pre><span></span><code>./x.py build
cp -a build/x86_64-unknown-linux-gnu/stage2/* ~/cargo_dev/stage2
cp -a build/x86_64-unknown-linux-gnu/stage2-tools-bin/* ~/cargo_dev/stage2/bin/
rustup toolchain link stage2 ~/cargo_dev/stage2
</code></pre></div>
<p>I think clone stock Miri, build and install it, and then test with a trivial package, using my new rust version:</p>
<div class="codehilite" data-code-language="Bash"><pre><span></span><code>rustup default stage2
rustc --version <span class="c1"># rustc 1.55.0-dev</span>
cargo --version <span class="c1"># cargo 1.55.0-dev</span>
git clone https://github.com/rust-lang/miri
<span class="nb">cd</span> miri
./miri build
./miri install
</code></pre></div>
<p>Finally, I think create a dummy package, build, and test to see if it works:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="cp">#[cfg(test)]</span><span class="w"></span>
<span class="k">mod</span> <span class="nn">tests</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="cp">#[test]</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">it_works</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="fm">assert_eq!</span><span class="p">(</span><span class="mi">2</span><span class="k">u8</span><span class="p">.</span><span class="n">wrapping_sub</span><span class="p">(</span><span class="mi">3</span><span class="k">u8</span><span class="p">),</span><span class="w"> </span><span class="mi">255</span><span class="k">u8</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>

<span class="w">    </span><span class="cp">#[test]</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">many_digits</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">s</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">"0."</span><span class="p">.</span><span class="n">to_string</span><span class="p">();</span><span class="w"></span>
<span class="w">        </span><span class="k">for</span><span class="w"> </span><span class="n">_</span><span class="w"> </span><span class="k">in</span><span class="w"> </span><span class="mi">0</span><span class="o">..</span><span class="mi">375</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="n">s</span><span class="p">.</span><span class="n">push</span><span class="p">(</span><span class="sc">'3'</span><span class="p">);</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>
<span class="w">        </span><span class="c1">// there's an older version that has an arithmetic overflow, which is expected, but didn't use wrapping_sub.</span>
<span class="w">       </span><span class="c1">// this therefore fails on the old library/core, but not on the new one.</span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">_</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">s</span><span class="p">.</span><span class="n">parse</span>::<span class="o">&lt;</span><span class="kt">f64</span><span class="o">&gt;</span><span class="p">();</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>

<span class="w">    </span><span class="cp">#[test]</span><span class="w"></span>
<span class="w">    </span><span class="cp">#[should_panic]</span><span class="w"></span>
<span class="w">    </span><span class="cp">#[allow(arithmetic_overflow)]</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">fails</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="fm">assert_eq!</span><span class="p">(</span><span class="mi">2</span><span class="k">u8</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">3</span><span class="k">u8</span><span class="p">,</span><span class="w"> </span><span class="mi">255</span><span class="k">u8</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>Running <code>cargo miri test</code> fails no matter how many times I try to rebuild rust, miri. I've also tried doing clean uninstalls of the toolchain by rebuilding the toolchain, deleting <code>~/cargo_dev/stage2</code>, deleting the <code>miri</code> directory, re-cloning, and rebuilding.</p>



<a name="244872997"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/building%20cargo-miri/near/244872997" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Huszagh (He/Him) <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/building.20cargo-miri.html#244872997">(Jul 04 2021 at 19:11)</a>:</h4>
<p>Attempting to change the actual code in libcore to say, not have a wrapping sub (and using an i8, rather than u8, with then a cast back, as a hack), doesn't do anything... I'm very much lost.</p>



<a name="244873049"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/building%20cargo-miri/near/244873049" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Huszagh (He/Him) <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/building.20cargo-miri.html#244873049">(Jul 04 2021 at 19:13)</a>:</h4>
<p>Attempting to do <code>./x.py install</code> fails, due to errors in <code>docs</code> (cannot find a library, since it uses nightly and not beta), and then removing that I have failures in <code>rustfmt</code>.</p>



<a name="244873051"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/building%20cargo-miri/near/244873051" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> The 8472 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/building.20cargo-miri.html#244873051">(Jul 04 2021 at 19:13)</a>:</h4>
<p>wrong thread?</p>



<a name="244873059"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/building%20cargo-miri/near/244873059" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Huszagh (He/Him) <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/building.20cargo-miri.html#244873059">(Jul 04 2021 at 19:13)</a>:</h4>
<p>Maybe, I'm asking in general because I'm not sure if it's a bug, t-compiler, or etc.</p>



<a name="244873132"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/building%20cargo-miri/near/244873132" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/building.20cargo-miri.html#244873132">(Jul 04 2021 at 19:15)</a>:</h4>
<p>It's fine to ask in General, but you posted in an existing thread. Don't worry, though, it happens quite often</p>



<a name="244873149"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/building%20cargo-miri/near/244873149" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Huszagh (He/Him) <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/building.20cargo-miri.html#244873149">(Jul 04 2021 at 19:15)</a>:</h4>
<p><span class="user-mention silent" data-user-id="203546">Laurențiu</span> <a href="#narrow/stream/122651-general/topic/Search.20PRs.20for.20a.20file/near/244873132">said</a>:</p>
<blockquote>
<p>It's fine to ask in General, but you posted in an existing thread. Don't worry, though, it happens quite often</p>
</blockquote>
<p>My mistake, I thought I had just clicked in general.</p>



<a name="244873206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/building%20cargo-miri/near/244873206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/building.20cargo-miri.html#244873206">(Jul 04 2021 at 19:17)</a>:</h4>
<p>There's a "New topic" button that shows up sometimes</p>



<a name="244876368"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/building%20cargo-miri/near/244876368" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/building.20cargo-miri.html#244876368">(Jul 04 2021 at 20:36)</a>:</h4>
<p><span class="user-mention" data-user-id="153718">@Alexander Huszagh (He/Him)</span> The miri repository has a <code>rust-toolchain</code> file which overrides which toolchain is used.   <code>rustup default</code> won't override that.  Perhaps that is causing it to use the wrong toolchain?</p>



<a name="244877109"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/building%20cargo-miri/near/244877109" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/building.20cargo-miri.html#244877109">(Jul 04 2021 at 20:54)</a>:</h4>
<p><code>./x.py</code> should use the bootstrap cargo and the right rustc instead of the rustup shims in <code>PATH</code>.</p>



<a name="244877110"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/building%20cargo-miri/near/244877110" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Huszagh (He/Him) <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/building.20cargo-miri.html#244877110">(Jul 04 2021 at 20:54)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120518">Eric Huss</span> <a href="#narrow/stream/122651-general/topic/building.20cargo-miri/near/244876368">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="153718">Alexander Huszagh (He/Him)</span> The miri repository has a <code>rust-toolchain</code> file which overrides which toolchain is used.   <code>rustup default</code> won't override that.  Perhaps that is causing it to use the wrong toolchain?</p>
</blockquote>
<p>It's possible, everything started working as expected when I  deleted <code>~/.cache/miri/HOST</code> and ran miri again.</p>



<a name="244877136"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/building%20cargo-miri/near/244877136" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Huszagh (He/Him) <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/building.20cargo-miri.html#244877136">(Jul 04 2021 at 20:55)</a>:</h4>
<p>So, I think it's just something where the miri cache wasn't being updated. Manually deleting it and then running it (first via <a href="https://github.com/rust-lang/miri-test-libstd">https://github.com/rust-lang/miri-test-libstd</a>) worked like a charm.</p>



<a name="244912572"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/building%20cargo-miri/near/244912572" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hyd-dev <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/building.20cargo-miri.html#244912572">(Jul 05 2021 at 09:20)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120518">Eric Huss</span> <a href="#narrow/stream/122651-general/topic/building.20cargo-miri/near/244876368">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="153718">Alexander Huszagh (He/Him)</span> The miri repository has a <code>rust-toolchain</code> file which overrides which toolchain is used.   <code>rustup default</code> won't override that.  Perhaps that is causing it to use the wrong toolchain?</p>
</blockquote>
<p>The repository doesn't have a <code>rust-toolchain</code> file. It just has a <a href="https://github.com/rust-lang/miri/blob/15e81a94b1aff99f7c38151d6976757ee0ed0097/rustup-toolchain">shell script</a> that runs <code>rustup toolchain override</code>.</p>



<a name="245009833"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/building%20cargo-miri/near/245009833" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/building.20cargo-miri.html#245009833">(Jul 06 2021 at 08:37)</a>:</h4>
<p>FWIW you shouldnt need <code>x.py</code> at all here :)</p>



<a name="245009847"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/building%20cargo-miri/near/245009847" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/building.20cargo-miri.html#245009847">(Jul 06 2021 at 08:37)</a>:</h4>
<p>just tell Miri where the stdlib sources are, it'll go and build them</p>



<a name="245009872"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/building%20cargo-miri/near/245009872" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/building.20cargo-miri.html#245009872">(Jul 06 2021 at 08:38)</a>:</h4>
<p>(but indeed it doesnt always notice when they change so it can be required to clear the cache)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>